<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set blocking/non-blocking mode on a stream</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.stream-select.html">stream_select</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.stream-set-chunk-size.html">stream_set_chunk_size</a></div>
 <div class="up"><a href="ref.stream.html">Stream 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.stream-set-blocking" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_set_blocking</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">stream_set_blocking</span> &mdash; <span class="dc-title">Set blocking/non-blocking mode on a stream</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-set-blocking-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>stream_set_blocking</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$stream</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>
   )</div>

  <p class="para rdfs-comment">
   Sets blocking or non-blocking mode on a <em><code class="parameter">stream</code></em>.
  </p>
  <p class="para">
   This function works for any stream that supports non-blocking mode
   (currently, regular files and socket streams).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-set-blocking-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">stream</code></em></dt>

     <dd>

      <p class="para">
       The stream.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">mode</code></em></dt>

     <dd>

      <p class="para">
       If <em><code class="parameter">mode</code></em> is 0, the given stream
       will be switched to non-blocking mode, and if 1, it
       will be switched to blocking mode.  This affects calls like
       <span class="function"><a href="function.fgets.html" class="function">fgets()</a></span> and <span class="function"><a href="function.fread.html" class="function">fread()</a></span>
       that read from the stream.  In non-blocking mode an
       <span class="function"><a href="function.fgets.html" class="function">fgets()</a></span> call will always return right away
       while in blocking mode it will wait for data to become available
       on the stream.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-set-blocking-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.stream-set-blocking-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.3.0</td>
       <td>
        Prior to PHP 4.3.0, this function only worked on socket based streams.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.stream-set-blocking-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    This function was previously called as
    <span class="function"><a href="function.set-socket-blocking.html" class="function">set_socket_blocking()</a></span> and later
    <span class="function"><a href="function.socket-set-blocking.html" class="function">socket_set_blocking()</a></span> but this usage is deprecated.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-set-blocking-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.stream-select.html" class="function" rel="rdfs-seeAlso">stream_select()</a> - Runs the equivalent of the select() system call on the given
   arrays of streams with a timeout specified by tv_sec and tv_usec</span></li>
  </ul>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.stream-select.html">stream_select</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.stream-set-chunk-size.html">stream_set_chunk_size</a></div>
 <div class="up"><a href="ref.stream.html">Stream 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
